/**
 * \file
 *           tlmRmtCfgElementPara.cpp
 * \brief
 *           Implements tlmRmtCfgElementPara class for Telematics services
 *           this is the class of parameter element of the message.
 *
 * \par Author (last changes):
 *          - Zeng Jie
 *          - BUIC, Continental Automotive Holdings Co., Ltd.
 * \par Project Leader:
 *          -
 * \par Responsible Developer:
 *          - Zeng Jie
 *          - BUIC, Continental Automotive Holdings Co., Ltd.
 * \par Responsible Architect:
 *          - Zhang Fa
 *          - BUIC, Continental Automotive Holdings Co., Ltd.
 *
 * \par Project:
 *      DPCA2
 *
 * \par SW-Component:
 *      Telematics
 *
 * \par SW-Package:
 *      Telematics
 *
 * \par SW-Module:
 *      Telematics Application
 *
* \par SW-Architecture Specification:
 *      DPCA2_TELEMATICS_SW_DD_07a_ready.doc
 *
* \par SW-Design Specification:
 *      DPCA2_TLM-RMTCFG_SW_DD_01d_released.doc
 *
 * \par SW-Test Case Specification:
 *
 * \par CM-Info:
 *
 * \note
 *      This is a note.
 *
 * \bug
 *      - there are no known bugs
 *
 * \par Module-History:
 *
 * \verbatim
 * Date                Author					Reason
 * 10 Dec 2013        Zeng Jie              Initial Creation
 * The latest entry at the head of the history list.
 * \endverbatim
 *
 * \par Copyright Notice:
 * Copyright (C) 2012 Continental Automotive Holdings Co., Ltd.
 * Alle Rechte vorbehalten. All Rights Reserved.\n
 * The reproduction, transmission or use of this document or its contents is
 * not permitted without express written authority.\n
 * Offenders will be liable for damages. All rights, including rights created
 * by patent grant or registration of a utility model or design, are reserved.
 *
 */

#include "stdafx.h"
#include "tlmService.h"
#include "tlmRmtCfgElementPara.h"
//## operation Fill(tlmRmtCfgSrvMsg,uint8_t)
#include "msgbuf.h"
//## operation Fill(tlmServiceMsg)
#include "tlmServiceMsg.h"


/**
* \brief tlmRmtCfgElementPara: this is constructor of tlmRmtCfgElementPara class
*
* \note
*
* \param[in]
* - code  :  code value of the element
*   size  : size of the element
*
* \return
* - none
*/
tlmRmtCfgElementPara::tlmRmtCfgElementPara(uint8_t code, uint32_t size) : tlmServiceElement(code, size) {
    //#[ operation tlmRmtCfgElementPara(uint8_t,uint32_t)
    //#]
}

/**
* \brief tlmRmtCfgElementPara: this is constructor of tlmRmtCfgElementPara class
*
* \note
*
* \param[in]
* - code  :  code value of the element
*
* \return
* - none
*/
tlmRmtCfgElementPara::tlmRmtCfgElementPara(uint8_t code) : tlmServiceElement(code,1) {
}

/**
* \brief tlmRmtCfgElementPara: this is default constructor of tlmRmtCfgElementPara class
*
* \note
*
* \param[in]
* - none
*
* \return
* - none
*/
tlmRmtCfgElementPara::tlmRmtCfgElementPara() : tlmServiceElement(0,1) {
}

/**
* \brief tlmRmtCfgElementPara: this is default destructor of tlmRmtCfgElementPara class
*                          It deletes all memory allcoated in the constructor function
*
* \note
*
* \param[in]
* - none
*
* \return
* - none
*/
tlmRmtCfgElementPara::~tlmRmtCfgElementPara() {
}

/**
* \brief Fill : fill the element buffer  with  code&value of the element
*              This is the element of paramenter, there is seperator between code and value
*
* \note
*
* \param[in]
* - srvMsg : the service message object that include the message buffer 
*
* \return
* - none
*
*/
void tlmRmtCfgElementPara::Fill(tlmServiceMsg& srvMsg) {
    //#[ operation Fill(tlmServiceMsg)
	srvMsg.SetValue(SEPERATE_LEVEL_3);
    srvMsg.SetValue(mCode);
    srvMsg.SetData(mValuePtr,mSize);
            
    //#]
}

/**
* \brief SetUpdatedFlag: set the updated flag as true
*                       This is parameter element, shall set it's flag
*                        
*
* \note
*
* \param[in]
* - none
*
* \return
* - none
*
*/
void tlmRmtCfgElementPara::SetUpdatedFlag() {
    //#[ operation SetUpdatedFlag()
    mIsUpdated = TRUE;
    //#]
}
/**
* \brief Fill : fill the element buffer  with  code&value of the element
*              This is the element of paramenter, there is seperator between code and value
*
* \note
*
* \param[in]
* - pMsgBuf : pointer to the message buffer that shall handle the element
*
* \return
* - none
*
*/
void tlmRmtCfgElementPara::Fill(msgbuf*& pMsgBuf) {
    if(NIL != pMsgBuf)
    {
        pMsgBuf->setValue(SEPERATE_LEVEL_3);
        pMsgBuf->setValue(mCode);    
        pMsgBuf->setData(mValuePtr,mSize);
    }
}


/**
* \brief  update : use another parameter element to update the this one
*
* \note
*
* \param[in]
* - pElePara : pointer to other parameter element
*
* \return
* - none
*
*/
void tlmRmtCfgElementPara::Update(tlmRmtCfgElementPara* pElePara) {
    if(NIL == pElePara)
    {
	    LOG_PRINT(DPCA_TELE_MAIN_ERROR,"[TLM_MSGSRV]:<%s>, pElePara is NIL\n", __FUNCTION__);
    }
    else
    {
        if(pElePara->IsUpdated())
        {//the element is updated
            SetValue(pElePara->GetValuePtr(), pElePara->GetActualSize());
        }
    }

}
